<?php

namespace JLPay\Models\Openmerch\Change;

use JLPay\Models\BaseRequest;

/**
 * 商户信息变更请求
 */
class MerchInfoChangeRequest extends BaseRequest
{
    /**
     * API URL
     */
    public const API_URL = '/open/merch/access/merch-info/modify';

    protected ?array $baseInfo = null;
    protected ?array $businessInfo = null;
    protected ?array $settleInfo = null;
    protected ?array $identificationInfo = null;

    /**
     * 检查是否需要加密
     *
     * @return bool
     */
    public function requiresEncrypt(): bool
    {
        return true;
    }

    /**
     * 获取敏感字段列表
     *
     * @return array
     */
    public function getSensitiveFields(): array
    {
        return [
            'identification_info.id_card_name',           // 经营者/法人姓名
            'identification_info.id_card_english_name',   // 经营者/法人英文名称
            'identification_info.id_card_no',             // 经营者/法人身份证件号码
            'identification_info.legal_person_phone',     // 经营者/法人手机号码
        ];
    }

    /**
     * 设置商户基础信息
     *
     * @param array $baseInfo
     * @return self
     */
    public function setBaseInfo(array $baseInfo): self
    {
        $this->baseInfo = $baseInfo;
        return $this;
    }

    /**
     * 设置商户业务信息
     *
     * @param array $businessInfo
     * @return self
     */
    public function setBusinessInfo(array $businessInfo): self
    {
        $this->businessInfo = $businessInfo;
        return $this;
    }

    /**
     * 设置结算信息
     *
     * @param array $settleInfo
     * @return self
     */
    public function setSettleInfo(array $settleInfo): self
    {
        $this->settleInfo = $settleInfo;
        return $this;
    }

    /**
     * 设置商户身份信息
     *
     * @param array $identificationInfo
     * @return self
     */
    public function setIdentificationInfo(array $identificationInfo): self
    {
        $this->identificationInfo = $identificationInfo;
        return $this;
    }

    /**
     * 转换为数组
     *
     * @return array
     */
    public function toArray(): array
    {
        $data = parent::toArray();
        
        if ($this->baseInfo) {
            $data['base_info'] = $this->baseInfo;
        }
        
        if ($this->businessInfo) {
            $data['business_info'] = $this->businessInfo;
        }
        
        if ($this->settleInfo) {
            $data['settle_info'] = $this->settleInfo;
        }
        
        if ($this->identificationInfo) {
            $data['identification_info'] = $this->identificationInfo;
        }
        
        return $data;
    }
} 